package 第五周;

/*
 * @author  YxinMiracle
 * @date  2022-05-01 17:30
 * @Gitee: https://gitee.com/yxinmiracle
 */

public class 寻找峰值 {

    public int findPeakElement(int[] nums) {
        int left = 0;
        int right = nums.length - 1;
        while (left < right){
            int lmin = (left + right) >> 1;
            int rmin = lmin + 1;
            if (nums[lmin] <= nums[rmin]){
                left = lmin + 1;
            }else {
                right = rmin - 1;
            }
        }
        return right;
    }

}
